﻿using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms.Design;
using System.Xml.Serialization;

namespace Landpy.CruiseControlNet.FacadeInterface.ConfigurationModule
{
    public class MSBuild : Task
    {
        [Category("Basic")]
        [Description(@"The location of the MSBuild.exe executable. (E.g: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe)")]
        [XmlElement("executable")]
        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        public string Executable { get; set; }

        [Category("Basic")]
        [Description("The name of the build project to run, relative to the workingDirectory.")]
        [XmlElement("projectFile")]
        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        public string ProjectFile { get; set; }

        [Category("Basic")]
        [Description("Any extra arguments to pass through to MSBuild.")]
        [XmlElement("buildArgs")]
        public string BuildArgs { get; set; }

        [Category("Basic")]
        [Description("Description used for the visualisation of the buildstage, if left empty the process name will be shown.")]
        [XmlElement("description")]
        public string Description { get; set; }

        [Category("Basic")]
        [Description("The priority class of the spawned process.")]
        [XmlElement("priority")]
        public PriorityType Priority { get; set; }

        [Category("Basic")]
        [Description("A semicolon-separated list of the targets to run.")]
        [XmlElement("targets")]
        public string Targets { get; set; }

        [Category("Basic")]
        [Description(@"The full path to the assembly containing the custom logger to use. Contrary to the usual MSBuild command line, " +
                        @"arguments MUST NOT be passed to the logger by appending them after the logger name separated by a semicolon. " +
                        @"You MUST use the loggerParameters property for this. Only if the assembly contains more than one logger implementation " +
                        @"you need to specify the logger class (see MSBuild reference): \[LoggerClass,\]LoggerAssembly" +
                        @"(E.g: C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll)")]
        [Editor(typeof(FileNameEditor), typeof(UITypeEditor))]
        [XmlElement("logger")]
        public string Logger { get; set; }

        [Category("Basic")]
        [Description("Number of seconds to wait before assuming that the process has hung and should be killed.")]
        [DefaultValue(600)]
        [XmlElement("timeout")]
        public int Timeout { get; set; }

        public MSBuild()
            : base(TaskType.MSBuild)
        {
            this.Executable = String.Empty;
            this.Logger = String.Empty;
        }
    }
}